package pl.textureStudio.view.panel
{
	import flash.events.MouseEvent;
	import com.bit101.components.PushButton;
	import pl.textureStudio.model.StudioModel;
	import com.bit101.components.Label;
	import pl.textureStudio.view.panel.base.BasePanel;

	import flash.display.Graphics;
	import flash.display.Shape;

	/**
	 * @author michalr
	 */
	public class WelcomePanel extends BasePanel
	{
		private static const FRAME_SIZE:uint = 10;
		internal static const PANEL_W:uint = 150;
		// ...
		private var panel:Shape;
		private var frame:Shape;
		// ...
		private var texturesCount : Label;
		private var bShowTexturesList : PushButton;
		
		public function WelcomePanel()
		{
			super();
		}

		override protected function init():void
		{
			var g:Graphics;
			var w:uint;
			var h:uint;
			var px : uint;
			var py : uint;
			frame = new Shape();
			panel = new Shape();
			// ...
			addChild( frame );
			addChild( panel );

			g = panel.graphics;
			g.beginFill( 0x333333 );
			w = Math.floor( (size.x - FRAME_SIZE * 2) * .8 );
			h = Math.floor( (size.y - FRAME_SIZE * 2) * .8 );
			px = FRAME_SIZE + Math.floor( ( size.x - FRAME_SIZE * 2 - w) * .5 );
			py = FRAME_SIZE + Math.floor( ( size.y - FRAME_SIZE * 2 - h) * .5 );
			g.drawRect( px, py, w, h );
			g.endFill();
			// ...
			g = frame.graphics;
			g.beginFill( 0, 1 );
			g.drawRect( 0, 0, size.x, size.y );
			g.drawRect( FRAME_SIZE, FRAME_SIZE, size.x - FRAME_SIZE * 2, size.y - FRAME_SIZE * 2 );
			g.endFill();
			g.beginFill( 0x3A3A3A, .9 );
			g.drawRect( FRAME_SIZE, FRAME_SIZE, size.x - FRAME_SIZE * 2, size.y - FRAME_SIZE * 2 );
			g.endFill();
			
			
			// ...
			var margin : uint = 7;
			var leftPos : uint = px + margin;
			var topPos : uint = py + margin;
			
			texturesCount = new Label(this,leftPos,topPos,'Textures in library : '+StudioModel.getInstance().dataLoadCount);
			texturesCount.textField.textColor = 0xFFFFFF;
			
			bShowTexturesList = new PushButton(this,texturesCount.x + texturesCount.width+20,topPos,'Textures list',onShowTexures);
		}
		
		
		override public function hide():void
		{
			
		}
		
		private function onShowTexures(e:MouseEvent):void
		{
			StudioModel.getInstance().showTexturesList();
		}
	}
}
